Toolbox = {
	table: function(doc){
		var tbl = $('<table width="100%" height="100" border="1" cellspacing="0" cellpadding="3"><tr><td></td><td></td></tr><tr><td></td><td></td></tr></table>').appendTo(doc.content);
		tbl.resizable({
			containment:"parent",
			maxWidth: doc.window.width()
		});
		tbl.find("td").dblclick(function(){
			var p=prompt("Html:", $(this).html());
			if(p !== null){
				$(this).html(p);
			}
		});
		return tbl;
	},
	image: function(doc){
		var img = $('<img src="" class="image-placeholder empty" />').appendTo(doc.content);
		
		img.resizable({
			containment: "parent"
		});
		img.dblclick(function(){
			var p=prompt("Source:", $(this).attr("src"));
			if(p !== null){
				$(this).attr("src", p);
				$(this).removeClass("empty");
			}
		});
		return img;
	},
	paragraph: function(doc){
		var p = $("<p>Some text...</p>").appendTo(doc.content);
		
		p.dblclick(function(){
			var p=prompt("Html:", $(this).html());
			if(p !== null){
				$(this).html(p);
			}
		});
		return p;
	}
}
$(function(){
	$("#toolbox li").draggable({
		helper:"clone",
		revert:"invalid",
		start: function(e, ui){
			ui.helper.addClass("shadow");
		}
	});
});